# Contributor: Dhruvin Gandhi <contact@dhruvin.dev>
# Maintainer: Dhruvin Gandhi <contact@dhruvin.dev>
pkgname=hledger-stockquotes
pkgver=0.1.2.1
pkgrel=0
pkgdesc="hledger addon that pulls historical stock prices for commodities"
url="https://github.com/prikhi/hledger-stockquotes#readme"
arch="x86_64" # limited by GHC
license="BSD-3-Clause"
makedepends="ghc cabal libffi-dev zlib-dev"
source="https://hackage.haskell.org/package/hledger-stockquotes-$pkgver/hledger-stockquotes-$pkgver.tar.gz
	cabal.project.freeze"

export CABAL_DIR="$srcdir"/cabal

prepare() {
	default_prepare
	cp "$srcdir"/cabal.project.freeze .
}

build() {
	cabal update
	cabal build --prefix=/usr --enable-relocatable
}

check() {
	cabal test
}

package() {
	local ghcver=$(ghc --version | cut -d " " -f 8)
	install -Dm755 \
		"dist-newstyle/build/$arch-linux/ghc-$ghcver/$pkgname-$pkgver/x/$pkgname/build/$pkgname/$pkgname" \
		"$pkgdir"/usr/bin/$pkgname
}

sha512sums="
7e1015e137765dce96ac289bef0d0bcc3344342285d33b1b3653ede9b9773582b5427e5d7ca6d2bacda8e3223e442d13ba304404a86f6358fd1660218a84c744  hledger-stockquotes-0.1.2.1.tar.gz
68a108247dad9ff53469a561855aee486e2d41567c9ec25299260652a41b60ac369a67b167ba3177ef639af811028dd04e17617115ef3286fa9e39d7707b4868  cabal.project.freeze
"
